﻿using System.Web.Mvc;
using System.Threading;

namespace CodeFirstMVC3.Web.Infrastructure
{
    public class BaseController : Controller
    {
        protected override void OnAuthorization(AuthorizationContext filterContext)
        {
            if (SessionPersister.SitePrincipal != null)
            {
                Thread.CurrentPrincipal = SessionPersister.SitePrincipal;
                filterContext.HttpContext.User = SessionPersister.SitePrincipal;
            }

            base.OnAuthorization(filterContext);
        }
    }
}